package com.cmcc.cmii.smsim.rest;

import com.cmcc.cmii.smsim.result.JsonResult;
import com.cmcc.cmii.smsim.service.IUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Thanks
 */
@RestController
@RequestMapping("/layim")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LayIMController {

    private final IUserService iUserService;
    /**
     * LayIM初始化
     * */
    @GetMapping("/init")
    public JsonResult getInitData(Long userId){

        return iUserService.getInitResult(userId);
    }

   /**
     * 获取群员列表
     * */
    @GetMapping("member")
    public JsonResult getGroupMembers(Long id){
        return iUserService.getMembersByGroupId(id);
    }

    /**
     * 获取消息记录
     **/
    @GetMapping("chat/history")
    public JsonResult getChatHistory(Long userId,Long id,String type,Long lastId){
        return iUserService.getChatRecords(userId ,id,type,lastId);
    }
}
